//
//  YXYZoomSelectionTableViewCell.m
//  Topit
//
//  Created by dllo on 15/12/8.
//  Copyright © 2015年 YXY. All rights reserved.
//

#import "YXYZoomSelectionTableViewCell.h"

@implementation YXYZoomSelectionTableViewCell
- (void)dealloc {
    [_selection release];
    [_dataSource release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selection = [[UILabel alloc] initWithFrame:CGRectZero];
        _selection.textColor = [UIColor grayColor];
        _selection.font = [UIFont systemFontOfSize:10];
        [self addSubview:_selection];
        [_selection release];
        
        for (int i = 0; i < 3; i++) {
            UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectZero];
            image.tag = 1000 + i;
            [self addSubview:image];
            [image release];
        }
    }
    return self;
}

-(void)setDataSource:(NSMutableArray *)dataSource {
    if (_dataSource != dataSource) {
        [_dataSource release];
        _dataSource = [dataSource retain];
    }
    for (int i = 0; i < dataSource.count; i++) {
        UIImageView *image = (UIImageView *)[self viewWithTag:1000 + i];
        [image sd_setImageWithURL:[NSURL URLWithString:dataSource[i]]];
    }
    
}

-(void)layoutSubviews {
    [super layoutSubviews];
    _selection.frame = CGRectMake(5, 15, self.width, 10);
    for (int i = 0; i < 3; i++) {
        UIImageView *image = (UIImageView *)[self viewWithTag:1000 + i];
        image.frame = CGRectMake(1 + i * image.width + 5 * i, _selection.bottom, (self.width / 3) - 5, 125);
    }
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
